<?php
/**
 *  Project     : CTS
 *  Created By  : Lanbo
 *  Data        : 090418
 */
class Cts_Plugin_Allow extends Zend_Controller_Plugin_Abstract
{
        
    public function preDispatch(Zend_Controller_Request_Abstract $objRequest)
    {
        $strModuleName = $objRequest->getModuleName();
        $strControllerName = $objRequest->getControllerName();
        $strActionName = $objRequest->getActionName();
        $strRule = $strModuleName.'.'.$strControllerName.'.'.$strActionName;      
		//echo($rule);
		if (( strcmp ( $strModuleName , "user" ) != 0  && ( strcmp ( $strControllerName , "login" ) != 0 || strcmp ( $strControllerName , "logout" ) != 0 ) ) && ( strcmp( $strModuleName , "default" ) != 0 ) && ( strcmp( $strModuleName , "cts" ) != 0 ))
        {
            if( Zend_Registry::isRegistered('nLoginId') )
            {
	            $nLoginId = Zend_Registry::get( 'nLoginId' );
	        }
	        else
	        {
	            $nLoginId = -1 ;
	        }
	        if ( $nLoginId > -1 )
	        {
	            $objRequest->setModuleName('error');
                $objRequest->setControllerName('error');
                $objRequest->setActionName('permissiondeny');
                $objRequest->setParam( 'Rule' , $strRule ) ;
	        }
    	}
    }
}